/*
 * @创建文件时间: 2021-06-03 00:50:28
 * @Auther: 猿小天
 * @最后修改人: 猿小天
 * @最后修改时间: 2021-11-20 11:09:28
 * 联系Qq:1638245306
 * @文件介绍:
 */

export const crudOptions = (vm) => {
  return {
    pageOptions: {
      compact: true
    },
    options: {
      tableType: 'vxe-table',
      rowKey: false,
      width: '100%',
      height: '100%' // 表格高度100%, 使用toolbar必须设置
    },
    rowHandle: false,
    indexRow: { // 或者直接传true,不显示title，不居中
      title: '序号',
      align: 'center',
      width: 100
    },
    viewOptions: {

      componentType: 'form'
    },
    formOptions: {
      defaultSpan: 12, // 默认的表单 span
      labelWidth: '130px'
    },
    columns: [{
      title: '关键词',
      key: 'search',
      show: false,
      disabled: true,
      search: {
        disabled: false
      },
      form: {
        disabled: true
      },
      view: { // 查看对话框组件的单独配置
        disabled: true
      }
    },
    {
      title: 'ID',
      key: 'id',
      show: false,
      width: 90,
      form: {
        disabled: true
      }
    },

    {
      title: '软件标识(appid)',
      key: 'app_id',
      search: {
        disabled: true
      },
      type: 'input',
      form: {
        value: vm.$route.query.app_id,
        component: {
          show: false,
          placeholder: '请输入软件标识',
          props: {
            clearable: true
          }
        },
        rules: [ // 表单校验规则
          { required: true, message: '请输入软件标识' }
        ],
        itemProps: {
          class: { yxtInput: true }
        }
      }
    },
    {
      title: '应用平台',
      key: 'platform',
      search: {
        disabled: false
      },
      type: 'select',
      dict: {
        data: [
          { label: 'Windows', value: 0 },
          { label: 'Linux', value: 1 }
        ]
      },
      form: {
        rules: [ // 表单校验规则
          { required: true, message: '必填项' }
        ],
        component: {
          span: 12,
          placeholder: '请选择应用平台'
        },
        editDisabled: true,
        itemProps: {
          class: { yxtInput: true }
        }
      }
    },
    {
      title: '版本号',
      key: 'version',
      search: {
        disabled: false
      },
      type: 'input',
      form: {
        rules: [ // 表单校验规则
          { required: true, message: '必填项' },
          { pattern: /^([0-9]\d|[0-9])(\.([0-9]\d|\d)){2}$/, message: '请输入正确的版本号' }
        ],
        component: {
          span: 12,
          placeholder: '请输入版本号'
        },
        editDisabled: true,
        itemProps: {
          class: { yxtInput: true }
        },
        helper: '版本号请以x.x.x的形式'
      }
    },

    {
      title: '设备号',
      key: 'device',
      search: {
        disabled: true
      },
      type: 'input',
      form: {
        value: true,
        component: {
          placeholder: ''
        }
      }
    }
    ]
  }
}
